home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_05
/
9n05113a
< prev
next >
Wrap
Text File
|
1991-03-22
|
713b
|
40 lines
/*
* xrt.c - cross-reference table
*/
.
.
struct treenode
{
char *word;
ln_seq lines;
treenode *left, *right;
treenode(unsigned);
};
treenode::treenode(unsigned n) : lines(n) { }
static treenode *addtree
(treenode *t, char *w, unsigned n)
{
int cond;
if (t == 0)
{
t = new treenode(n);
t->word = new char[strlen(w) + 1];
strcpy(t->word, w);
t->left = t->right = 0;
}
else if ((cond = strcmp(w, t->word)) == 0)
t->lines.add(n);
else if (cond < 0)
t->left = addtree(t->left, w, n);
else
t->right = addtree(t->right, w, n);
return t;
}
.
.